package chapter04;

public class Test05_throw1 {
    public static void main(String[] args) {
        setAge(10);
        setAge(-10);
    }
    static void setAge(int age) throws RuntimeException{
        if(age<0){
            //明确的抛出异常 抛出运行状态的异常
            throw new RuntimeException("年龄不能为负数");
        }else{
            System.out.println("年龄为："+age);
        }
    }
}
